<?php

require_once 'MCAPI.class.php';
require_once 'config.inc.php';

$api = new MCAPI($apikey);


$retval = $api->campaigns();
 
if ($api->errorCode){
	echo "Unable to Pull list of Campaign!";
	echo "\n\tCode=".$api->errorCode;
	echo "\n\tMsg=".$api->errorMessage."\n";
} else {
    echo sizeof($retval['total'])." Total Campaigns Matched.<br />\n";
    echo sizeof($retval['data'])." Total Campaigns returned:<br />\n";
    foreach($retval['data'] as $c){
        $idArray[] = $c['id'];
    }
}
foreach($idArray as $id) {
	$retId = $api->campaignStats($id);
	if ($api->errorCode){
	echo "Unable to Load Campaign Stats!";
	echo "<br />\n\tCode=".$api->errorCode;
	echo "<br />\n\tMsg=".$api->errorMessage."<br />\n";
	} else {
    	echo "Stats for ".$retId."<br />\n";
    	foreach($retId as $k=>$v){
        	echo "\t".$k." => ".$v."<br />\n";
    	}	
	}	
}

?>
